package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 充值商品
 */
public class RechargeCfg extends BaseCfg<RechargeCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "recharge";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.RechargeCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 7;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","价格","类型（道具，月卡，礼包等）","商品id","渠道商品id","渠道id","渠道appid",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","price","type","goodsId","channelGoodsId","channelId","channelAppId",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","price","type","goodsId","channelGoodsId","channelId","channelAppId",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,106934601,3575610,207037201,-609147762,1461735806,-108938279,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","float","int","int","int","int","int",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Float.class,Integer.class,Integer.class,Integer.class,Integer.class,Integer.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 价格
	 */
	private float price;
	
	/**
	 * 类型（道具，月卡，礼包等）
	 */
	private int type;
	
	/**
	 * 商品id
	 */
	private int goodsId;
	
	/**
	 * 渠道商品id
	 */
	private int channelGoodsId;
	
	/**
	 * 渠道id
	 */
	private int channelId;
	
	/**
	 * 渠道appid
	 */
	private int channelAppId;
	
	
	
	public static RechargeCfg builder() {
		RechargeCfg rechargeCfg = new RechargeCfg();
		return rechargeCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 价格
	 */
	public float getPrice() {
		return price;
	}
	
	/**
	 * 类型（道具，月卡，礼包等）
	 */
	public int getType() {
		return type;
	}
	
	/**
	 * 商品id
	 */
	public int getGoodsId() {
		return goodsId;
	}
	
	/**
	 * 渠道商品id
	 */
	public int getChannelGoodsId() {
		return channelGoodsId;
	}
	
	/**
	 * 渠道id
	 */
	public int getChannelId() {
		return channelId;
	}
	
	/**
	 * 渠道appid
	 */
	public int getChannelAppId() {
		return channelAppId;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.price;
        values[2] = this.type;
        values[3] = this.goodsId;
        values[4] = this.channelGoodsId;
        values[5] = this.channelId;
        values[6] = this.channelAppId;
        return values;
	}
	
	protected RechargeCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.price = (float)vals[1];
		this.type = (int)vals[2];
		this.goodsId = (int)vals[3];
		this.channelGoodsId = (int)vals[4];
		this.channelId = (int)vals[5];
		this.channelAppId = (int)vals[6];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.price);
        map.put(keys[2], this.type);
        map.put(keys[3], this.goodsId);
        map.put(keys[4], this.channelGoodsId);
        map.put(keys[5], this.channelId);
        map.put(keys[6], this.channelAppId);
        return map;
    }
    
    protected RechargeCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.price = (float)map.get(keys[1]);
   		this.type = (int)map.get(keys[2]);
   		this.goodsId = (int)map.get(keys[3]);
   		this.channelGoodsId = (int)map.get(keys[4]);
   		this.channelId = (int)map.get(keys[5]);
   		this.channelAppId = (int)map.get(keys[6]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.price);
        obj.put(keys[2], this.type);
        obj.put(keys[3], this.goodsId);
        obj.put(keys[4], this.channelGoodsId);
        obj.put(keys[5], this.channelId);
        obj.put(keys[6], this.channelAppId);
        return obj;
    }
    
    protected RechargeCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.price = obj.getFloatValue(keys[1]);
	    this.type = obj.getIntValue(keys[2]);
	    this.goodsId = obj.getIntValue(keys[3]);
	    this.channelGoodsId = obj.getIntValue(keys[4]);
	    this.channelId = obj.getIntValue(keys[5]);
	    this.channelAppId = obj.getIntValue(keys[6]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeFloat(this.price);
	    byteBuf.writeInt(this.type);
	    byteBuf.writeInt(this.goodsId);
	    byteBuf.writeInt(this.channelGoodsId);
	    byteBuf.writeInt(this.channelId);
	    byteBuf.writeInt(this.channelAppId);
    }
	
	protected RechargeCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.price = byteBuf.readFloat(null);
	    this.type = byteBuf.readInt(null);
	    this.goodsId = byteBuf.readInt(null);
	    this.channelGoodsId = byteBuf.readInt(null);
	    this.channelId = byteBuf.readInt(null);
	    this.channelAppId = byteBuf.readInt(null);
	    return this;
	}
	
	public RechargeCfg deepCopy(){
		RechargeCfg rechargeCfg = null;
		try {
			rechargeCfg = (RechargeCfg) super.clone();
			return rechargeCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return rechargeCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
